package com.whfc.ms.api.emp.service.impl;

import com.whfc.common.result.ListData;
import com.whfc.common.result.PageData;
import com.whfc.emp.dto.AppEmpGroupEmpDTO;
import com.whfc.emp.dto.AppHelmetDTO;
import com.whfc.emp.service.AppHelmetService;
import com.whfc.entity.dto.OssPathDTO;
import com.whfc.ms.api.emp.service.MsAppHelmetService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.Date;
import java.util.List;

/**
 * @ClasssName MsAppHelmetServiceImpl
 * @Description 人员安全帽接口
 * @Author hw
 * @Date 2021/1/4 14:25
 * @Version 1.0
 */
@Slf4j
@Service
public class MsAppHelmetServiceImpl implements MsAppHelmetService {

    @DubboReference(interfaceClass = AppHelmetService.class, version = "1.0.0")
    private AppHelmetService appHelmetService;

    @Override
    public PageData<AppHelmetDTO> helmetLatest(Integer pageNum, Integer pageSize, Integer deptId, Integer corpId, Integer groupId, String keyword) {
        return appHelmetService.helmetLatest(pageNum, pageSize, deptId, corpId, groupId, keyword);
    }

    @Override
    public PageData<AppHelmetDTO> helmetLog(Integer pageNum, Integer pageSize, Integer deptId, Integer corpId, Integer groupId, String keyword, Date date) {
        return appHelmetService.helmetLog(pageNum, pageSize, deptId, corpId, groupId, keyword, date);
    }

    @Override
    public OssPathDTO helmetLatestDataExport(Integer deptId, Integer corpId, Integer groupId, String keyword) throws IOException {
        return appHelmetService.helmetLatestDataExport(deptId, corpId, groupId, keyword);
    }

    @Override
    public OssPathDTO helmetLogDataExport(Integer deptId, Integer corpId, Integer groupId, String keyword, Date date) throws IOException {
        return appHelmetService.helmetLogDataExport(deptId, corpId, groupId, keyword, date);
    }

    @Override
    public ListData<AppEmpGroupEmpDTO> helmetEmpList(Integer deptId, String keyword) {
        List<AppEmpGroupEmpDTO> list = appHelmetService.helmetEmpList(deptId, keyword);
        return new ListData<>(list);
    }

    @Override
    public String getToken() {
        return appHelmetService.getToken();
    }

    @Override
    public void test111(String type) {
         appHelmetService.test111(type);
//        appHelmetService.refreshHelmetData();
    }

    @Override
    public void setHelmetData(String mockData) {
        appHelmetService.setHelmetData(mockData);
    }

    @Override
//    @Scheduled(cron = "0 * * * * ?")
//    @Scheduled(fixedDelay = 10*1000)
    public void refreshHelmetData() {
//        log.info("refresh helmet data start!");
        appHelmetService.refreshHelmetData();
    }
}
